// 本地存储方案二
interface orderinfo {
  orderNo: string | undefined | null;
  orderTime: string | undefined | null;
  payUrl: string | undefined | null;
  qrCode: string | undefined | null;
  timeout: number;
}
import { defineStore } from "pinia";
export const useStore = defineStore("nuxtStore", {
  // 推荐用于完整类型推断的箭头函数
  state: () => {
    return {
      // 所有这些属性都将自动推断其类型
      lang: {},
      ranks: false as boolean,
      firstLoading: false as boolean,
      terouro: false as boolean,
      turnTable: false as boolean,
      langAppear: false as boolean,
      avatar: "" as string,
      task: false as boolean,
      changeAvatar: false as boolean,
      topnavopen: false as boolean,
      orderinfo: {} as orderinfo,
      isRecord: 0,
      rechangeType: 2 as number,
      rechange: false as boolean,
      withdrawal: false as boolean,
      IsCollapse: false as boolean,
      loginopen: false as boolean,
      loginoreroll: "login" as null | undefined | string,
      token: "" as null | undefined | string,
      userinfo: {} as any,
      cointype: "BRL" as string,
      coininfo: {} as any,
      accountremember: false as boolean,
      account: "" as null | undefined | string,
      accountpassword: "" as null | undefined | string,
      remember: false as boolean,
      mobile: "" as null | undefined | string,
      password: "" as null | undefined | string,
    };
  },
  actions: {
    useIsCollapse(val: boolean) {
      this.IsCollapse = val;
    },
    useloginopen(val: boolean) {
      this.loginopen = val;
    },
    useloginoreroll(val: null | undefined | string) {
      this.loginoreroll = val;
    },
    usetoken(val: null | undefined | string) {
      this.token = val;
    },
    useuserinfo(val: any) {
      this.userinfo = val;
    },
    usecointype(val: string) {
      this.cointype = val;
    },
    usecoininfo(val: any) {
      this.coininfo = val;
    },
    useaccountremember(val: boolean) {
      this.accountremember = val;
    },
    useaccount(val: null | undefined | string) {
      this.account = val;
    },
    useaccountpassword(val: null | undefined | string) {},
    useremember(val: boolean) {
      this.remember = val;
    },
    usemobile(val: null | undefined | string) {
      this.mobile = val;
    },
    usepassword(val: null | undefined | string) {
      this.password = val;
    },
  },
  //持久化
  persist: process.client && {
    storage: localStorage,
    paths: [
      "lang",
      "token",
      "userinfo",
      "cointype",
      "coininfo",
      "accountremember",
      "account",
      "accountpassword",
      "remember",
      "password",
      "mobile",
      "avatar",
    ],
  },
});
